Skip to content

test: add property-based tests with FsCheck#93

Merged
Reefact merged 2 commits into
mainfrom
claude/fuzzing-openssf-scorecard-uneno2
Jul 11, 2026
Merged

test: add property-based tests with FsCheck#93
Reefact merged 2 commits into
mainfrom
claude/fuzzing-openssf-scorecard-uneno2

Conversation

@Reefact

@Reefact Reefact commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Introduces a new FirstClassErrors.PropertyTests project containing property-based tests using FsCheck. These tests verify the monad laws for Outcome<T>, validate invariants of ErrorCode and ErrorDescription, and exercise the library's validating factories with fuzzing-style inputs. This satisfies Scorecard's Fuzzing check and provides richer behavioral coverage than hand-written examples alone.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Analyzer / diagnostic change
  • Tests
  • Documentation
  • Build / CI / tooling

Changes

  • Added FirstClassErrors.PropertyTests project targeting .NET 10.0 with FsCheck 3.3.3
  • Implemented OutcomeMonadLawTests: property-based verification of left identity, right identity, associativity, functor identity, and error propagation by reference identity
  • Implemented ErrorCodePropertyTests: verification that error codes round-trip through string conversions, equality is ordinal, and blank/null codes are rejected
  • Implemented ErrorDescriptionPropertyTests: verification of message trimming, normalization idempotence, blank message handling, and validation of mandatory fields
  • Added PropertyTestSupport.cs with custom FsCheck generators (NonBlank(), Blank()) and assertion helpers (Expect.Throws<T>()) for fuzzing-style inputs
  • Updated FirstClassErrors.sln to include the new test project
  • Updated maintainers/workflows/scorecard.en.md and maintainers/workflows/scorecard.fr.md to document the Fuzzing check implementation and version constraints

Testing

  • dotnet build FirstClassErrors.sln
  • dotnet test FirstClassErrors.sln

Documentation

  • Scorecard workflow documentation updated to explain property-based testing implementation and v5.5.0 version requirement

Related issues

https://claude.ai/code/session_014W1zrcBNy3jEs8ngAQKwZg

claude added 2 commits July 11, 2026 07:09
Add FirstClassErrors.PropertyTests, an FsCheck-based project that exercises the
core value objects and result type with randomly generated input:

- ErrorCode: verbatim round-trip through ToString and the implicit string
  conversion, ordinal equality, and rejection of blank or null codes.
- ErrorDescription: trimming, idempotent normalization, blank-detail collapse,
  and rejection of blank or null mandatory messages.
- Outcome<T>: the monad laws (left and right identity, associativity), reference
  propagation of the original error on failure, To/Then consistency, and the
  Recover and Finally semantics.

The bare `using FsCheck;` also gives OpenSSF Scorecard a C# property-based
fuzzing signal for its Fuzzing check.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014W1zrcBNy3jEs8ngAQKwZg
Record why FirstClassErrors.PropertyTests exists from a Scorecard standpoint and
the tooling-version caveat: C# property-based detection (FsCheck) landed in
scorecard v5.5.0, while [email protected] still bundles v5.3.0, so the
Fuzzing sub-check only turns green once the scan runs on >= v5.5.0. Kept in sync
across the English and French maintainer notes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_014W1zrcBNy3jEs8ngAQKwZg
@Reefact Reefact merged commit 996c271 into main Jul 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants